<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <button @click="msg = 'hello' ">修改msg</button>
        <p>{{ msg }}</p>
    </div>

    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                msg: '你好'
            },
            watch: {
                msg (newVal, oldVal) {
                    console.log('msg被修改了', newVal, oldVal)
                }
            }
        })
    </script>
</body>
</html>